#include <iostream>

using namespace std;

typedef long long LL;

LL get_max(int n, int r1, int s1, int p1, int r2, int s2, int p2)
{
    LL ret = 0;
    // 赢
    int minr_s = min(r1, s2);
    ret += minr_s;
    r1 -= minr_s, s2 -= minr_s;
    int mins_p = min(s1, p2);
    ret += mins_p;
    s1 -= mins_p, p2 -= mins_p;
    int minp_r = min(p1, r2);
    ret += minp_r;
    p1 -= minp_r, r2 -= minp_r;

    // 平局
    int minr_r = min(r1, r2);
    r1 -= minr_r, r2 -= minr_r;
    int mins_s = min(s1, s2);
    s1 -= mins_s, s2 -= mins_s;
    int minp_p = min(p1, p2);
    p1 -= minp_p, p2 -= minp_p;

    // 输
    int mins_r = min(s1, r2);
    s1 -= mins_r, r2 -= mins_r;
    ret -= mins_r;
    int minr_p = min(r1, p2);
    r1 -= minr_p, p2 -= minr_p;
    ret -= minr_p;
    int minp_s = min(p1, s2);
    p1 -= minp_s, s2 -= minp_s;
    ret -= minp_s;

    return ret;
}

LL get_min(int n, int r1, int s1, int p1, int r2, int s2, int p2)
{
    LL ret = 0;
    // 输
    int mins_r = min(s1, r2);
    s1 -= mins_r, r2 -= mins_r;
    ret -= mins_r;
    int minr_p = min(r1, p2);
    r1 -= minr_p, p2 -= minr_p;
    ret -= minr_p;
    int minp_s = min(p1, s2);
    p1 -= minp_s, s2 -= minp_s;
    ret -= minp_s;
    
    // 平局
    int minr_r = min(r1, r2);
    r1 -= minr_r, r2 -= minr_r;
    int mins_s = min(s1, s2);
    s1 -= mins_s, s2 -= mins_s;
    int minp_p = min(p1, p2);
    p1 -= minp_p, p2 -= minp_p;

    // 赢
    int minr_s = min(r1, s2);
    ret += minr_s;
    r1 -= minr_s, s2 -= minr_s;
    int mins_p = min(s1, p2);
    ret += mins_p;
    s1 -= mins_p, p2 -= mins_p;
    int minp_r = min(p1, r2);
    ret += minp_r;
    p1 -= minp_r, r2 -= minp_r;

    return ret;
}

void solve()
{
    int n, r1, s1, p1, r2, s2, p2;
    cin >> n >> r1 >> s1 >> p1 >> r2 >> s2 >> p2;
    cout << get_max(n, r1, s1, p1, r2, s2, p2) << " "
         << get_min(n, r1, s1, p1, r2, s2, p2) << endl;
}

int main()
{
    int T; cin >> T;
    while(T--) solve();
    return 0;
}